/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package baseDatos;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author oracle
 */
public class BaseDeDatos {
    private String URL = "jdbc:oracle:thin:@localhost:1521:sales";
    private String driver = "oracle.jdbc.OracleDriver";
    private String usuario = "bancosol";
    private String passwd = "bancosol";

    protected Connection conexion = null;

    public BaseDeDatos() {
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(BaseDeDatos.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("El driver no es correcto");
        }
    }

    protected boolean ConectarBD() {
        try {
            conexion = DriverManager.getConnection(URL, usuario, passwd);
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(BaseDeDatos.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("La conexión no se ha realizado");
            return false;
        }
    }

    protected boolean DesconectarBD() {
        try {
            if (conexion != null) {
                conexion.close();
                return true;
            } else
                return false;
        } catch (SQLException ex) {
            Logger.getLogger(BaseDeDatos.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
}
